import request from "@/request/request";
import qs from "qs"

export function getAddressList(data){
    let url = "/app/address";
    let param = {
        url:url,
        method:"GET",
        params:data
    }
    return request(param);
}


/**
 * 获取默认的收获地址
 * @returns {Promise<AxiosResponse<any>>}
 */
export function getDefaultAddress(){
    let url = "/app/address/default";
    let param = {
        url:url,
        method:"GET"
    }
    return request(param);
}


export function saveAddress(id,address){
    let method = "post";
    let url = "/app/address";
    if(id){
        method = "put";
        url = "/app/address/"+id;
    }

    let param = {
        url:url,
        method:method,
        data:qs.stringify(address)
    }
    return request(param);
}


export function findById(id){
    let param = {
        url:"/app/address/"+id,
        method:"get"
    }
    return request(param);
}

export function deleteAddressById(id){
    let param = {
        url:"/app/address/"+id,
        method:"delete"
    }
    return request(param);
}








